﻿
namespace gbL.NetBoard.Filters
{
    public interface IFilter<TFilter, TTest>
    {
        /// <summary>
        /// Records a filtered object for the specified owner. Appends to any existing list of filtered objects.
        /// </summary>
        /// <param name="owner">Owner of the filter list</param>
        /// <param name="toFilter">Object to be used for filtering</param>
        void AddFilter(object owner, TFilter toFilter);
        /// <summary>
        /// Allows a filter to precalculate and cache the result of filter evaluations, prior to calling IsFiltered
        /// </summary>
        /// <param name="toTest">Object to test against filters</param>
        void Precalculate(TTest toTest);
        /// <summary>
        /// Tests whether the specified object owns any filter lists
        /// </summary>
        /// <param name="owner">Object for which to query for filter lists</param>
        /// <returns>True if the object owns a list of filters</returns>
        bool HasFilter(object owner);
        /// <summary>
        /// Tests whether the specified object is allowed through any of the filters for the specified owner. 
        /// If the owner has no specified filters, returns true.
        /// </summary>
        /// <param name="owner">Owner of the filter list</param>
        /// <param name="toMatch">Object to test against the list</param>
        /// <returns>True if the object gets through any of the filters, otherwise false</returns>
        bool IsAllowed(object owner, TTest toTest);
    }
}
